package com.hongye.school.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hongye.school.domain.dto.FangSchoolDto;
import com.hongye.school.domain.vo.FangSchoolVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hongye.common.log.annotation.Log;
import com.hongye.common.log.enums.BusinessType;
import com.hongye.common.security.annotation.RequiresPermissions;
import com.hongye.common.domain.FangSchool;
import com.hongye.school.service.IFangSchoolService;
import com.hongye.common.core.web.controller.BaseController;
import com.hongye.common.core.web.domain.AjaxResult;
import com.hongye.common.core.utils.poi.ExcelUtil;
import com.hongye.common.core.web.page.TableDataInfo;

/**
 * 学校列表Controller
 * 
 * @author hdd
 * @date 2025-01-09
 */
@RestController
@RequestMapping("/school")
public class FangSchoolController extends BaseController
{
    @Autowired
    private IFangSchoolService fangSchoolService;

    /**
     * 查询学校列表列表
     */
    @RequiresPermissions("school:school:schoolList")
    @GetMapping("/schoolList")
    public TableDataInfo schoolList(@RequestBody FangSchoolDto fangSchoolDto)
    {
        startPage();
        List<FangSchoolVo> list = fangSchoolService.selectFangSchoolList(fangSchoolDto);
        return getDataTable(list);
    }

    /**
     * 新增学校列表
     */
    @RequiresPermissions("school:school:addSchool")
    @Log(title = "学校列表", businessType = BusinessType.INSERT)
    @PostMapping("/addSchool")
    public AjaxResult addSchool(@RequestBody FangSchool fangSchool)
    {
        return toAjax(fangSchoolService.insertFangSchool(fangSchool));
    }




//    /**
//     * 导出学校列表列表
//     */
//    @RequiresPermissions("school:school:export")
//    @Log(title = "学校列表", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, FangSchool fangSchool)
//    {
//        List<FangSchool> list = fangSchoolService.selectFangSchoolList(fangSchool);
//        ExcelUtil<FangSchool> util = new ExcelUtil<FangSchool>(FangSchool.class);
//        util.exportExcel(response, list, "学校列表数据");
//    }

    /**
     * 获取学校列表详细信息
     */
    @RequiresPermissions("school:school:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(fangSchoolService.selectFangSchoolById(id));
    }



    /**
     * 修改学校列表
     */
    @RequiresPermissions("school:school:edit")
    @Log(title = "学校列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FangSchool fangSchool)
    {
        return toAjax(fangSchoolService.updateFangSchool(fangSchool));
    }

    /**
     * 删除学校列表
     */
    @RequiresPermissions("school:school:remove")
    @Log(title = "学校列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(fangSchoolService.deleteFangSchoolByIds(ids));
    }
}
